#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 410;

int n, m, sx, sy;
bool st[N][N];
int g[N][N];
int dis[8][2] = {{-2, 1}, {-1, 2}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}, {1, 2}, {2, 1}};

void bfs(){
    queue<PII> q;
    q.push({sx, sy});
    st[sx][sy] = true;
    g[sx][sy] = 0;

    while(!q.empty()){
        PII temp = q.front();
        q.pop();
        int tx = temp.first, ty = temp.second;
        for(int i = 0; i < 8; i ++){
            int nx = tx + dis[i][0], ny = ty + dis[i][1];
            if(nx < 1 || nx > n || ny < 1 || ny > m) continue;
            if(st[nx][ny]) continue;
            g[nx][ny] = g[tx][ty] + 1;
            st[nx][ny] = true;
            q.push({nx, ny});
        }

    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m >> sx >> sy;
    memset(g, -1, sizeof g);
    g[sx][sy] = 0;

    bfs();
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            cout << g[i][j] << " ";
        }
        cout << '\n';
    }

    return 0;
}